<?php
require_once(dirname(__FILE__)."/../../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../admin/libs/power_class.php");
$mc=new libstr();
$pw=new power();
$cataid=0;
if($_GET["id"]!=""){
$cataid=$_GET["id"];
}
$mid=$_GET["mid"]?$_GET["mid"]:0;
$parr=array();
$power=$db->ds("select * from power_class where ID=".$mid."");
if($mc->Ismp($power[0]["quanxian"])!=""){
	$parr=explode(",",$power[0]["quanxian"]);
}
//print_r($parr);

$sql="select ID,classname,rootid,(select count(b.ID) as tt from powercontent_class as b where b.pid=t.ID) as tj from powercontent_class as t where t.pid=".$cataid."";
 $getrs=$db->ds($sql);
//print_r($getrs);
header("Content-Type:text/xml;");
echo '<?xml version="1.0" encoding="utf-8"'.'?'.'>';
echo '<tree id="'.$cataid.'">';
 if(count($getrs)>0){
for($i=0;$i<count($getrs);$i++){
//echo '<item text="'.$getrs[$i][classname].'" id="'.$getrs[$i][ID].'"  child="'.$getrs[$i]["tj"].'" />';

if($getrs[$i]["tj"]==0){
	
if(in_array($getrs[$i][ID],$parr)){
echo '<item text="'.$getrs[$i][classname].'" id="'.$getrs[$i][ID].'"  child="'.$getrs[$i]["tj"].'" checked="1"/>';	
}else{
echo '<item text="'.$getrs[$i][classname].'" id="'.$getrs[$i][ID].'"  child="'.$getrs[$i]["tj"].'" />';	
}
//echo '<item text="'.$getrs[$i][classname].'" id="'.$getrs[$i][ID].'"  child="'.$getrs[$i]["tj"].'" />';	
}else{
	//nocheckbox代表是否显示选择框
 echo '<item text="'.$getrs[$i][classname].'" id="'.$getrs[$i][ID].'"  child="'.$getrs[$i]["tj"].'" nocheckbox="1"/>';

}
}
 }

//echo '</item>';

echo '</tree>';
?>

